<style>
  ol.bulletpoints li {
    list-style-type: decimal;
    list-style-position: inside;
  }
</style>
<script>
  function submitForm(elt) {
    elt.submit();
    elt.disable();
    return false;
  }
</script>
<h1 class="admin-page-title"><%= message('update_center.page') -%></h1>
<p class="admin-page-description"><%= message('update_center.page.description') -%></p>
<%= render :partial => 'updatecenter/tabs', :locals => {:tab => 'system_updates'} -%>

<div class="tabs-panel">

  <%= render :partial => 'updatecenter/operations' -%>

  <% if @update_plugin_center %>
    <% if @sonar_updates.empty? %>
      <table class="data width100 marginbottom10">
        <thead>
        <tr>
          <td></td>
        </tr>
        </thead>
        <tbody>
        <tr class="even">
          <td>System is up to date.</td>
        </tr>
        </tbody>
      </table>
    <% else %>

      <% @sonar_updates.to_a.reverse.each do |update|
        release=update.getRelease()
      %>
        <table class="data width100" id="sonar-<%= release.getVersion() -%>">
          <thead>
          <tr>
            <th><h2>SonarQube <%= release.getVersion() -%></h2></th>
          </tr>
          </thead>
          <tbody>
          <tr class="even">
            <td>
              <table class="width100 spaced">
              <tbody style="vertical-align: top">
                <tr>
                  <td class="thin nowrap"><b>Date: </b></td>
                  <td class="sep"></td>
                  <td><%= release_date(release.getDate()) if release.getDate() -%></td>
                </tr>
                <tr>
                  <td class="thin nowrap">
                    <b><%= link_to_if release.getChangelogUrl(), 'Release Notes', release.getChangelogUrl(), :class => 'external' %>
                      : </b></td>
                  <td class="sep"></td>
                  <td><%= release.getDescription() -%></td>
                </tr>
                <tr>
                  <td class="thin nowrap" valign="top"><b>How to upgrade: </b></td>
                  <td class="sep"></td>
                  <td>
                    <% if update.hasWarnings() %>
                      Follow those steps to upgrade SonarQube from version <%= sonar_version -%> to
                      version <%= release.getVersion() -%> :
                      <ol class="bulletpoints">
                        <li>Stop SonarQube</li>
                        <li><%= link_to 'Download', release.getDownloadUrl(), :class => 'external' -%> and install
                          SonarQube <%= release.getVersion() -%> after having carefully read the <a href="http://docs.codehaus.org/display/SONAR/Upgrading" class="external">upgrade guide</a>.
                        </li>
                        <% update.getIncompatiblePlugins().each do |incompatible_plugin| %>
                        <li>
                            Uninstall the plugin <%= incompatible_plugin.getName() -%> which is not compatible with
                            SonarQube <%= release.getVersion() -%>.
                          </form>
                        </li>
                        <% end %>
                        <% update.getPluginsToUpgrade().each do |plugin_to_upgrade| %>
                        <li>
                            Replace current version of plugin <%= plugin_to_upgrade.getArtifact().getName() -%> by
                            version <%= plugin_to_upgrade.getVersion() -%>
                          </form>
                        </li>
                        <% end %>
                        <li>Start SonarQube</li>
                      </ol>

                    <% else %>
                      <%= link_to 'Download', release.getDownloadUrl(), :class => 'external' -%> and install
                      SonarQube <%= release.getVersion() -%> after having carefully read the <a href="http://docs.codehaus.org/display/SONAR/Upgrading" class="external">upgrade guide</a>.
                    <% end %>
                  </td>
                </tr>
              </tbody>
              </table>
            </td>
          </tr>
          </tbody>
        </table>
        <div class="break30"></div>
      <% end
         end
         end %>

  <%= render :partial => 'updatecenter/status', :locals => {:action => 'system_updates'} %>
</div>
